﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Itech_Run.Blog.EntityFrameworkCore.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Blog_Focus",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    PersonId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    FocusOnId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_Focus", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Blog_Info",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    Author = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    Category = table.Column<int>(type: "int", nullable: false),
                    Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsPublish = table.Column<bool>(type: "bit", nullable: true),
                    AllowComment = table.Column<bool>(type: "bit", nullable: true),
                    IsTop = table.Column<bool>(type: "bit", nullable: true),
                    WhoVisit = table.Column<int>(type: "int", nullable: true),
                    IsDel = table.Column<bool>(type: "bit", nullable: true),
                    TopTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    DelTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_Info", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Blog_Personal",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    UserId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    Hometown = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    CurrentAddress = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    MarriageStatus = table.Column<int>(type: "int", nullable: true),
                    Position = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    WorkUnit = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    WorkingStatus = table.Column<int>(type: "int", nullable: true),
                    InterestedTechnologies = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    TheRecentGoals = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    Motto = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    SelfIntroduction = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    Wechat = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    QQ = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_Personal", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Blog_PersonCategory",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    UserId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Description = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    IsVisible = table.Column<bool>(type: "bit", nullable: true),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_PersonCategory", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Blog_PersonLabel",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    UserId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_PersonLabel", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Blog_Collect",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    BlogId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    CollectId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_Collect", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Blog_Collect_Blog_Info_BlogId",
                        column: x => x.BlogId,
                        principalTable: "Blog_Info",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Blog_Comment",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    BlogId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    RelationCommentId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsChecked = table.Column<bool>(type: "bit", nullable: true),
                    IsAnonymous = table.Column<bool>(type: "bit", nullable: true),
                    NickName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_Comment", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Blog_Comment_Blog_Info_BlogId",
                        column: x => x.BlogId,
                        principalTable: "Blog_Info",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Blog_Interest",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    BlogId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    ReadNum = table.Column<int>(type: "int", nullable: true),
                    RecommendNum = table.Column<int>(type: "int", nullable: true),
                    OpposeNum = table.Column<int>(type: "int", nullable: true),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_Interest", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Blog_Interest_Blog_Info_BlogId",
                        column: x => x.BlogId,
                        principalTable: "Blog_Info",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Blog_PersonCategory_Map",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    BlogId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    PersonCategoryId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_PersonCategory_Map", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Blog_PersonCategory_Map_Blog_Info_BlogId",
                        column: x => x.BlogId,
                        principalTable: "Blog_Info",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Blog_PersonCategory_Map_Blog_PersonCategory_PersonCategoryId",
                        column: x => x.PersonCategoryId,
                        principalTable: "Blog_PersonCategory",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Blog_PersonLabel_Map",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    BlogId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    PersonLabelId = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: false),
                    CreatedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "dateTime", nullable: true),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(36)", maxLength: 36, nullable: true),
                    LastModifiedTime = table.Column<DateTime>(type: "dateTime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Blog_PersonLabel_Map", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Blog_PersonLabel_Map_Blog_Info_BlogId",
                        column: x => x.BlogId,
                        principalTable: "Blog_Info",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Blog_PersonLabel_Map_Blog_PersonLabel_PersonLabelId",
                        column: x => x.PersonLabelId,
                        principalTable: "Blog_PersonLabel",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Blog_Collect_BlogId",
                table: "Blog_Collect",
                column: "BlogId");

            migrationBuilder.CreateIndex(
                name: "IX_Blog_Comment_BlogId",
                table: "Blog_Comment",
                column: "BlogId");

            migrationBuilder.CreateIndex(
                name: "IX_Blog_Interest_BlogId",
                table: "Blog_Interest",
                column: "BlogId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Blog_PersonCategory_Map_BlogId",
                table: "Blog_PersonCategory_Map",
                column: "BlogId");

            migrationBuilder.CreateIndex(
                name: "IX_Blog_PersonCategory_Map_PersonCategoryId",
                table: "Blog_PersonCategory_Map",
                column: "PersonCategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_Blog_PersonLabel_Map_BlogId",
                table: "Blog_PersonLabel_Map",
                column: "BlogId");

            migrationBuilder.CreateIndex(
                name: "IX_Blog_PersonLabel_Map_PersonLabelId",
                table: "Blog_PersonLabel_Map",
                column: "PersonLabelId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Blog_Collect");

            migrationBuilder.DropTable(
                name: "Blog_Comment");

            migrationBuilder.DropTable(
                name: "Blog_Focus");

            migrationBuilder.DropTable(
                name: "Blog_Interest");

            migrationBuilder.DropTable(
                name: "Blog_Personal");

            migrationBuilder.DropTable(
                name: "Blog_PersonCategory_Map");

            migrationBuilder.DropTable(
                name: "Blog_PersonLabel_Map");

            migrationBuilder.DropTable(
                name: "Blog_PersonCategory");

            migrationBuilder.DropTable(
                name: "Blog_Info");

            migrationBuilder.DropTable(
                name: "Blog_PersonLabel");
        }
    }
}
